package com.gaohe.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gaohe.mapper.UserCardMapper;
import com.gaohe.pojo.UserCard;
import com.gaohe.service.UserCardService;
import com.google.gson.internal.NonNullElementWrapperList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserCardServiceImpl extends ServiceImpl<UserCardMapper,UserCard> implements UserCardService {
    @Autowired
    private UserCardMapper userCardMapper;
    @Override
    public List<UserCard> getCardsByUserId(Long id) {
        List<UserCard> userCards =  userCardMapper.getCardsByUserId(id);
        return userCards;
    }
    //根据用户id和会员卡id判断此卡是否已持有 用户端
    @Override
    public UserCard getByUserIdAndCardId(Long userId, Long cardId) {
        LambdaQueryWrapper<UserCard> qw = new LambdaQueryWrapper<>();
        qw.eq(UserCard::getUserId,userId);
        qw.eq(UserCard::getCardId,cardId);
        UserCard userCard = this.getOne(qw);
        return userCard;
    }
}
